package com.yh.service;


import com.yh.mapper.BookMapper;
import com.yh.pojo.Books;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//@Service
public class BookServiceImpl implements BookService {
//    记住一句话，service层调用dao层: 所以一定要组合起来
//    @Autowired
    private BookMapper bookMapper;

//    给个setter   方便给spring注入
    public void setBookMapper(BookMapper bookMapper) {
        this.bookMapper = bookMapper;
    }


//    操作dao层来使用
    public int addBook(Books books) {
        return bookMapper.addBook(books);
    }

    public int deleteBookById(int id) {
        return bookMapper.deleteBookById(id);
    }

    public int updateBook(Books book) {
        return bookMapper.updateBook(book);
    }

    public Books queryBookById(int id) {
        return bookMapper.queryBookById(id);
    }

    public List<Books> queryAllBook() {
        return bookMapper.queryAllBook();
    }

    public Books queryBookByName(String bookName) {
        return bookMapper.queryBookByName(bookName);
    }
}
